package com.hzncc.flowable_diboot.custom_field.entity;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.lang.Double;
import java.math.BigDecimal;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.builder.HashCodeExclude;
import org.hibernate.validator.constraints.Length;
import com.diboot.core.util.D;
import com.diboot.core.entity.BaseModel;
import com.diboot.core.entity.BaseEntity;
import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 过滤项配置 Entity 定义
 *
 * @author MyName
 * @version 1.0
 * @date 2024-11-14
 * Copyright © MyCorp
 */
@TableName("mdl_filter_setting")
@Getter
@Setter
@Accessors(chain = true)
public class FilterSetting extends BaseModel {
    private static final long serialVersionUID = 1555310573574420449L;
    /**
     * 租户
     */
    @NotNull(message = "租户不能为空")
    @TableField()
    private String tenantId;

    /**
     * 字段名
     */
    @Length(max = 100, message = "字段名长度应小于100")
    @BindQuery(comparison = Comparison.LIKE)
    @TableField()
    private String fieldName;

    /**
     * 标签名
     */
    @Length(max = 100, message = "标签名长度应小于100")
    @BindQuery(comparison = Comparison.LIKE)
    @TableField()
    private String labelName;

    /**
     * 条件
     */
    @TableField(value = "`condition`")
    private String condition;

    /**
     * 默认值
     */
    @Length(max = 100, message = "默认值长度应小于100")
    @BindQuery(comparison = Comparison.LIKE)
    @TableField()
    private String defaulValue;

    /**
     * 自定义表格配置id
     */
    @Length(max = 32, message = "自定义表格配置id长度应小于32")
    @BindQuery(comparison = Comparison.LIKE)
    @TableField()
    private String customTableConfigId;

    /**
     * 控件类型
     */
    @TableField
    private String controlType;

    /**
     * 控件参数
     */
    @TableField
    private String controlParam;

    /**
     * 范围标识
     */
    @TableField
    private String rangeFlag;


    @JsonIgnore
    public String getConditionChar() {
        return switch (this.condition) {
            case "eq" -> "=";
            case "ne" -> "!=";
            case "gt" -> ">";
            case "ge" -> ">=";
            case "lt" -> "<";
            case "le" -> "<=";
            case "like" -> "like";
            case "in" -> "in";
            default -> throw new IllegalStateException("Unexpected value: " + this.condition);
        };
    }
}